<?php

namespace app\admin\model\system\admin;

use app\customer\curd\PagingInterface;
use app\model\admin\Admin;
use Illuminate\Pagination\LengthAwarePaginator;

class AdminList extends Admin implements PagingInterface
{
    //验证器规则
    public function rules() :array
    {
        return [
            'page'              => 'min:1|max:100',
            'page_size'         => 'min:1|max:100',
        ];
    }

    //验证器消息提示
    public function messages() :array
    {
        return [];
    }

    //分页查询数据返回分页对象
    public function paging(array $params) :LengthAwarePaginator
    {
        return static::paginate($params["page_size"]??10);
    }

    //返回值统一字段名
    public function toArray() :array
    {
        return [
            "id" => $this->id,
        ];
    }
}